package Function_Study.comprehensive;

import java.util.ArrayList;
import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        /*
            练习2:
                创建集合添加学生对象,学生对象属性:name,age
                只获取姓名并放到数组当中(使用方法引用完成)
                "雏鹤爱,12", "樱岛麻衣,16", "小鸟游六花,14", "时崎狂三,18", "四糸乃,11", "夜刀神十香,19"
         */
        ArrayList<Student> students = new ArrayList<>();
        students.add(new Student("雏鹤爱",12));
        students.add(new Student("樱岛麻衣",16));
        students.add(new Student("小鸟游六花",14));
        students.add(new Student("时崎狂三",18));
        students.add(new Student("四糸乃",11));

        String[] names = students.stream().map(Student::getName).toArray(String[]::new);
        System.out.println(Arrays.toString(names));
    }
}
